package com.faker.tools.util;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class PushTest {


    public static void main(String[] args) {
        PushTest pushTest = new PushTest();
        pushTest.test1();
    }

    public void test1() {
        HttpRequest httpRequest = HttpUtil.createPost("http://10.180.103.228:9318/gitsync/sync/test");
        httpRequest.header("X-Gitlab-Event", "Push Hook");
        httpRequest.body("{\n" +
                "  \"object_kind\": \"push\",\n" +
                "  \"event_name\": \"push\",\n" +
                "  \"before\": \"768da1c5005a393c19034475eb1576542d33e59f\",\n" +
                "  \"after\": \"a4d0884d565f1851242743404db9e43082f25aff\",\n" +
                "  \"ref\": \"refs/heads/feature/触点融通服务\",\n" +
                "  \"ref_protected\": false,\n" +
                "  \"checkout_sha\": \"a4d0884d565f1851242743404db9e43082f25aff\",\n" +
                "  \"message\": null,\n" +
                "  \"user_id\": 2,\n" +
                "  \"user_name\": \"anlinxi\",\n" +
                "  \"user_username\": \"anlinxi\",\n" +
                "  \"user_email\": null,\n" +
                "  \"user_avatar\": \"http://3e7653f30ec9/uploads/-/system/user/avatar/2/cloud.png\",\n" +
                "  \"project_id\": 345,\n" +
                "  \"project\": {\n" +
                "    \"id\": 345,\n" +
                "    \"name\": \"辽宁移动微服务uni-app\",\n" +
                "    \"description\": \"辽宁移动微服务uni-app项目\",\n" +
                "    \"web_url\": \"http://3e7653f30ec9/anlinxi/lnwlcsMicroServiceUniApp\",\n" +
                "    \"avatar_url\": null,\n" +
                "    \"git_ssh_url\": \"git@3e7653f30ec9:anlinxi/lnwlcsMicroServiceUniApp.git\",\n" +
                "    \"git_http_url\": \"http://gitlab.anlinxi.top:30000/anlinxi/lnwlcsMicroServiceUniApp.git\",\n" +
                "    \"namespace\": \"anlinxi\",\n" +
                "    \"visibility_level\": 0,\n" +
                "    \"path_with_namespace\": \"anlinxi/lnwlcsMicroServiceUniApp\",\n" +
                "    \"default_branch\": \"master\",\n" +
                "    \"ci_config_path\": \"\",\n" +
                "    \"homepage\": \"http://3e7653f30ec9/anlinxi/lnwlcsMicroServiceUniApp\",\n" +
                "    \"url\": \"git@3e7653f30ec9:anlinxi/lnwlcsMicroServiceUniApp.git\",\n" +
                "    \"ssh_url\": \"git@3e7653f30ec9:anlinxi/lnwlcsMicroServiceUniApp.git\",\n" +
                "    \"http_url\": \"http://gitlab.anlinxi.top:30000/anlinxi/lnwlcsMicroServiceUniApp.git\"\n" +
                "  },\n" +
                "  \"commits\": [\n" +
                "    {\n" +
                "      \"id\": \"8d8c3c87cf0bab9746402a3a75346bc5478569a4\",\n" +
                "      \"message\": \"线下投诉集成触点融通查询\\n\",\n" +
                "      \"title\": \"线下投诉集成触点融通查询\",\n" +
                "      \"timestamp\": \"2024-10-11T17:38:58+08:00\",\n" +
                "      \"url\": \"http://3e7653f30ec9/anlinxi/lnwlcsMicroServiceUniApp/-/commit/8d8c3c87cf0bab9746402a3a75346bc5478569a4\",\n" +
                "      \"author\": {\n" +
                "        \"name\": \"anlinxi\",\n" +
                "        \"email\": \"[REDACTED]\"\n" +
                "      },\n" +
                "      \"added\": [\n" +
                "\n" +
                "      ],\n" +
                "      \"modified\": [\n" +
                "        \"pages/jikeCityObstacle/process/jikeCompleteProcess.vue\"\n" +
                "      ],\n" +
                "      \"removed\": [\n" +
                "\n" +
                "      ]\n" +
                "    },\n" +
                "    {\n" +
                "      \"id\": \"a4d0884d565f1851242743404db9e43082f25aff\",\n" +
                "      \"message\": \"低满集成触点融通查询\\n\",\n" +
                "      \"title\": \"低满集成触点融通查询\",\n" +
                "      \"timestamp\": \"2024-10-11T17:45:47+08:00\",\n" +
                "      \"url\": \"http://3e7653f30ec9/anlinxi/lnwlcsMicroServiceUniApp/-/commit/a4d0884d565f1851242743404db9e43082f25aff\",\n" +
                "      \"author\": {\n" +
                "        \"name\": \"anlinxi\",\n" +
                "        \"email\": \"[REDACTED]\"\n" +
                "      },\n" +
                "      \"added\": [\n" +
                "\n" +
                "      ],\n" +
                "      \"modified\": [\n" +
                "        \"pages/common/components/cdrtService.vue\",\n" +
                "        \"pages/jiakeSinceDebug/process/jikeCompleteProcess.vue\"\n" +
                "      ],\n" +
                "      \"removed\": [\n" +
                "\n" +
                "      ]\n" +
                "    }\n" +
                "  ],\n" +
                "  \"total_commits_count\": 2,\n" +
                "  \"push_options\": {\n" +
                "  },\n" +
                "  \"repository\": {\n" +
                "    \"name\": \"辽宁移动微服务uni-app\",\n" +
                "    \"url\": \"git@3e7653f30ec9:anlinxi/lnwlcsMicroServiceUniApp.git\",\n" +
                "    \"description\": \"辽宁移动微服务uni-app项目\",\n" +
                "    \"homepage\": \"http://3e7653f30ec9/anlinxi/lnwlcsMicroServiceUniApp\",\n" +
                "    \"git_http_url\": \"http://gitlab.anlinxi.top:30000/anlinxi/lnwlcsMicroServiceUniApp.git\",\n" +
                "    \"git_ssh_url\": \"git@3e7653f30ec9:anlinxi/lnwlcsMicroServiceUniApp.git\",\n" +
                "    \"visibility_level\": 0\n" +
                "  }\n" +
                "}");
        HttpResponse httpResponse = httpRequest.execute();
        int status = httpResponse.getStatus();
        String responseBody = httpResponse.body();
        log.info("状态码:{}", status);
        log.info("响应体:{}", responseBody);
    }
}
